﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;


using CeA.Reports.Atendimento.DataAccess.DTO;
using System.Web.SessionState;

namespace CeA.Reports.Atendimento.Web.inc.Helpers {
    public class AuthSessionHelper {
        private static HttpSessionState session = HttpContext.Current.Session;
        private UsuarioDTO m_identity = null;

        private AuthSessionHelper() {
        }

        public UsuarioDTO Identity {
            get {
                if (session[".ASPXAUTH"] != null)
                    return (session[".ASPXAUTH"] as UsuarioDTO);
                
                return m_identity; 
            }
        }

        public static AuthSessionHelper CreateNew(UsuarioDTO user) {
            session.Add(".ASPXAUTH", user);
            return new AuthSessionHelper();
        }
    }
}
